$(function() {
	//判断缓存是否存在
	var obj = JSON.parse(localStorage.getItem("goods_info"));
	console.log(obj);
	var shuxing = obj.shuxingzhi;
	var img = obj.img;
	var title = obj.title;
	var bid = localStorage.getItem("bid");
	var oid = localStorage.getItem("oid");
	showData(shuxing,img,title);
	
	//将缓存的数据展示到页面上
	function showData(shuxingzhi,img,title){
		var show = $(".show");
		var goods_detail = $('<div class="goods"><img src= ' + img + ' /></div><div class="detail_info"><p>' + title + '</p><p>' + shuxingzhi + '</p><p class="fill" style="display:none" >填写物流信息</p></div>');
		show.append(goods_detail);
	}
	console.log(oid,bid);
	
	//判断状态，显示按钮
	//1是待处理，2是审核成功，3是拒绝
		$.ajax({
				url: "http://a.91jfk.com/Product/Ordershop/ReturnState",
				type: "post",
				data: {
					orderid: oid,
					branchid: bid
				},
				datatype: "json",
				success: function(xhr) {
					console.log(xhr);
					var data = JSON.parse(xhr);
					console.log(data);
					if(data.message == "1") {
						$(".pending_content .pend p").text("审核中");
						
					} else if(data.message == "2"){
						$(".pending_content .pend p").text("审核成功");
						$(".fill").show();
					}else if(data.message == "3"){
						$(".pending_content .pend p").text("已拒绝");
						setTimeout(function() {
							window.location.href = "tuihuanhuoOrder.html";
						}, 2000);
						
					}else if(data.message == "4"){
						$(".pending_content .pend p").text("用户寄回");
						setTimeout(function() {
							window.location.href = "tuihuanhuoOrder.html";
						}, 2000);
					}else if(data.message == "5"){
						$(".pending_content .pend p").text("卖家签收");
						setTimeout(function() {
							window.location.href = "tuihuanhuoOrder.html";
						}, 2000);
					}
				}
			})
	$(".fill").click(function() {
		var storage = window.localStorage;
			storage.setItem("fenid",bid);
			storage.setItem("mainid",oid);
		
		window.location.href = "fill_logistics.html";
	});
});